import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';

import pxtovw from 'postcss-px-to-viewport'
import path from "path";

import { viteMockServe } from 'vite-plugin-mock'
const loder_pxtovw = pxtovw({
    selectorBlackList: [".ignore-"],
    customFun: ({ file }) => {

        // 这个自定义的方法是针对处理vant组件下的设计稿为375问题
        const designWidth = path.join(file).includes(path.join("node_modules", "vant")) ? 375 : 750;
        return designWidth;
    },
})



// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(), viteMockServe({
            supportTs: false,
            logger: false,
            mockPath: "./mock/"
        }),
        Components({
            resolvers: [VantResolver()],
        }),
    ],
    resolve: {
        alias: {
            "@": path.resolve(__dirname, './src'),
        },
    },
    css: {
        postcss: {
            plugins: [loder_pxtovw]
        }
    },

})